package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.SubjectMapper;
import com.xxx.modules.entity.Subject;
import com.xxx.modules.service.SubjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * subject
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-04-29
 */
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> implements SubjectService {

    @Autowired
    private SubjectMapper subjectMapper;


    @Override
    public PageInfo<Subject> selectSubjectInfo(Subject subject, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Subject> wrapper = new QueryWrapper<>();
        List<Subject> data = subjectMapper.selectListInfo(subject);
        return new PageInfo<>(data);
    }

    @Override
    public void saveSubjectInfo(Subject subject) {
        subjectMapper.insert(subject);
    }

    @Override
    public void updateSubjectInfo(Subject subject) {
        subjectMapper.updateById(subject);
    }

    @Override
    public void delSubjectInfo(Integer id) {
        subjectMapper.deleteById(id);
    }

    @Override
    public void delBatchSubjectInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        subjectMapper.deleteBatchIds(list);
    }


}